<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05员工表格练习</title>
</head>
<body>
<input type="text" id="i1" placeholder="请输入员工姓名">
<input type="text" id="i2" placeholder="请输入员工工资">
<input type="text" id="i3" placeholder="请输入员工岗位">
<button onclick="addEmp()">添加员工</button>
<hr>
<table border="1px">
    <caption>员工表</caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>岗位</th>
    </tr>
</table>
<script>
    function addEmp(){
        let arr = [];
        let input1=document.getElementById('i1').value;
        let input2=document.getElementById('i2').value;
        let input3=document.getElementById('i3').value;
        console.log(input1);
        console.log(input2);
        console.log(input3);
        let trE=document.createElement('tr');
        let td1=document.createElement('td');
        let td2=document.createElement('td');
        let td3=document.createElement('td');
        td1.innerHTML=input1;
        td2.innerHTML=input2;
        td3.innerHTML=input3;
        trE.append(td1,td2,td3);
        let tableE=document.querySelector('table');
        tableE.append(trE);
        document.getElementById('i1').value='';
        document.getElementById('i2').value='';
        document.getElementById('i3').value='';
        arr.push({name: input1, salary: input2,job:input3});
        console.log(arr);
    }
</script>
</body>
</html>